import { useState } from "react"
const Ipt = props => {
    //解构props中的数据
    let { onAdd } = props;
    let [val, setVal] = useState("")
    let handleChange = (e) => {
        // console.log(e.target.value)
        setVal(e.target.value)
    }
    return (
        <div className="todo-input">
            <input type="text" value={val} onChange={handleChange} />
            <button onClick={() => {
                onAdd(val)
                setVal("") //将输入值清空
            }}>点击增加</button>
        </div>
    )
}

export default Ipt